@echo off

rem 设置监听的端口号

set port=80

echo port : %port%

for /f "usebackq tokens=1-5" %%a in (`netstat -ano ^| findstr %port%`) do (

if [%%d] EQU [LISTENING] (

set pid=%%e

)

)

for /f "usebackq tokens=1-5" %%a in (`tasklist ^| findstr %pid%`) do (

set program_name=%%a

)

echo now will kill process : pid %pid%, program_name %program_name%

pause

rem 根据进程ID，kill进程

taskkill /f /pid %pid%

pause
